<?php
$this->breadcrumbs=array(
	Yii::t('breadcrumb', 'Access control')=>array('/authorization/main'),
	Yii::t('breadcrumb', 'Permissions'),
);
?>

<?php $this->renderPartial('_menu'); ?>

<h1><?php echo Yii::t('auth', 'Permissions'); ?></h1>

<table class="authTable permissionTable" border="0" cellpadding="0" cellspacing="0">

	<tr>

		<th class="nameColumn" style="width:30%;"><?php echo Yii::t('auth', 'Item description'); ?></th>

		<?php foreach( $roleHierarchy as $role ): ?>

			<th class="roleColumn" style="width:<?php echo $roleColumnWidth;?>%"><?php echo ucfirst($role->name); ?></th>

		<?php endforeach; ?>

	</tr>

	<?php $i=0; ?>

	<?php foreach( $authItems as $name => $authItem ): ?>

		<tr class="<?php echo $i%2===0 ? 'odd' : 'even'; ?>">

			<td><?php echo CHtml::encode($authItem->name); ?></td>

			<?php foreach( $roleHierarchy as $role ): ?>

				<td>

					<?php if( isset($authChildMap[ $role->name ][ $name ])===true ): ?>

						<?php if( $role->hasChild($name)===true ): ?>

							<?php echo CHtml::link(Yii::t('auth', 'Revoke'), array('authItem/revoke', 'name'=>$role->name, 'child'=>$name)); ?>

						<?php else: ?>

							<?php echo Yii::t('auth', 'Inherited'); ?>

						<?php endif; ?>

					<?php else: ?>

						<?php if( $auth->authItemIsAssigned($name)===false ): ?>

							<?php echo CHtml::link(Yii::t('auth', 'Assign'), array('authItem/assign', 'name'=>$role->name, 'child'=>$name)); ?>

						<?php else: ?>

							<?php echo Yii::t('auth', 'No'); ?>

						<?php endif; ?>

					<?php endif; ?>

				</td>

			<?php endforeach; ?>

		</tr>

		<?php ++$i; ?>

	<?php endforeach; ?>

</table>
